var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = cc._decorator,
    s = r.ccclass,
    c = r.property,
    p =
        (r.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.dirList = [];
                e.rotateNode = null;
                e.bodyAnimal = null;
                e.pathClip = {};
                e.curPlay = "";
                e.catAnimal = {};
                e.catBodyAnimal = {};
                return e;
            }
            e.prototype.onLoad = function () {
                this.loadClips();
            };
            e.prototype.loadClips = function () {
                this.catBodyAnimal.rotateKey = "rotate01";
                this.catAnimal.waitKey = "wait01";
                this.catAnimal.walkKey = "walk01";
                this.catAnimal.cookBack = "cookBack01";
                this.catAnimal.cookFront = "cookFront01";
                this.catAnimal.cookLeft = "cooksideLeft01";
                this.catAnimal.cookRight = "cooksideRight01";
                for (var t in this.catBodyAnimal) this.addClipRotate(this.catBodyAnimal[t]);
                for (var t in this.catAnimal) this.addClipBody(this.catAnimal[t]);
            };
            e.prototype.addClipRotate = function (t) {
                var e = this;
                this.pathClip[t] ||
                    this.loadPath(t, function (o, a) {
                        a && !e.pathClip[t] && (e.pathClip[t] = a);
                    });
            };
            e.prototype.addClipBody = function (t) {
                var e = this;
                this.pathClip[t] ||
                    this.loadPath(t, function (o, a) {
                        if (a && !e.pathClip[t]) {
                            e.pathClip[t] = a;
                            e.bodyAnimal.addClip(a, t);
                        }
                    });
            };
            e.prototype.loadPath = function (t, e) {
                BundleManager.loadRes(BundleManager.bn.Res, "/UI/catAnimal/" + t, cc.AnimationClip, e);
            };
            e.prototype.playWalk = function () {
                var t = this;
                this.pathClip[this.catAnimal.walkKey]
                    ? this.bodyAnimal.play(this.catAnimal.walkKey)
                    : this.scheduleOnce(function () {
                          t.playWalk();
                      }, 0.5);
            };
            e.prototype.resetAnimalAnlge = function () {
                this.rotateNode && (this.rotateNode.angle = 0);
            };
            e.prototype.playWait = function () {
                var t = this;
                if (this.pathClip[this.catAnimal.waitKey]) {
                    if (this.pathClip[this.catAnimal.waitKey]) {
                        this.bodyAnimal.play(this.catAnimal.waitKey);
                        this.resetAnimalAnlge();
                    }
                } else
                    this.scheduleOnce(function () {
                        t.playWait();
                    }, 0.5);
            };
            e.prototype.playCooking = function (t) {
                var e = !0,
                    o = "";
                switch (t) {
                    case 0:
                        o = this.catAnimal.cookFront;
                        break;
                    case 1:
                        this.setDirList(!0);
                        o = this.catAnimal.cookLeft;
                        break;
                    case 2:
                        this.setDirList(!1);
                        o = this.catAnimal.cookRight;
                        break;
                    default:
                        e = !1;
                        o = this.catAnimal.cookBack;
                }
                if ("" != o) {
                    this.bodyAnimal.play(o);
                    this.resetAnimalAnlge();
                }
                return e;
            };
            e.prototype.setDirList = function (t) {
                for (var e = t ? 1 : -1, o = 0; o < this.dirList.length; o++) this.dirList[o].scaleX = e;
            };
            e.prototype.playRotate = function () {};
            n([c([cc.Node])], e.prototype, "dirList", void 0);
            n([c(cc.Node)], e.prototype, "rotateNode", void 0);
            n([c(cc.Animation)], e.prototype, "bodyAnimal", void 0);
            return n([s], e);
        })(cc.Component));
o.default = p;
